#include <stdio.h>
#include <stdlib.h>

int cishu(int n,int x){
  int count=0;
  while(n>0){
    int t=n%10;
    if(t==x){
      count++;
    }
    n=n/10;
  }
  return count;
}
int main(int argc, char *argv[])
{
  // 请在此输入您的代码
  int n,x;
  scanf("%d%d",&n,&x);
  int sum=0;
  for(int i=1;i<=n;i++){
    int count=cishu(i,x);
    sum+=count;
  }
  printf("%d",sum);
  return 0;
}